import { Injectable } from '@angular/core';
import { HttpService } from '../providers/HttpService';
import { map, mergeMap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { FileService } from '../providers/FileService';
import { ValidationErrors } from '@angular/forms';
import * as constants from '../providers/Constants'
import { HttpHelper, RequestSetting } from '../providers/HttpHelper';
@Injectable({
    providedIn: 'root'
})
export class ShopService {
    constructor(public http: HttpService, public fileService: FileService) {
    }

    // 获取商品列表
    getProcList(data, setting: RequestSetting = {}) {
        return this.http.post(constants.ApiServeNoLogin.getProcList, data, setting);
    }

   // 获取热门搜索
   selHotProc(data, setting: RequestSetting = {}) {
        return this.http.post(constants.ApiServeNoLogin.selHotProc, data, setting);
    }



    // 获取商品商选列表
    getProcStandards(data, setting: RequestSetting = {}) {
        return this.http.post(constants.ApiServeNoLogin.getProcStandards, data, setting);
    }




    // 获取推荐商品列表
    getRecommendProc(data, setting: RequestSetting = {}) {
        return this.http.post(constants.ApiServeNoLogin.getRecommendProc, data, setting);
    }

    // 获取最新商品
    getSelFaceNewProcList(data, setting: RequestSetting = {}) {
        return this.http.post(constants.ApiServeNoLogin.getSelFaceNewProcList, data, setting);
    }

    // 获取商品列表
    queryProcClass(data) {
        return this.http.post(constants.ApiServeNoLogin.queryProcClass, data);
    }
    // 获取商品详情
    getProcDetail(data) {
        return this.http.post(constants.ApiServeNoLogin.getProcDetail, data);
    }

    // 收藏
    getAddCollect(data) {
        return this.http.post(constants.ApiServeLogin.getAddCollect, data);
    }


    // 收藏列表
    getSelProcCollect(data) {
        return this.http.post(constants.ApiServeLogin.getSelProcCollect, data);
    }



    // 查询购物车
    queryShoppingCar(data) {
        return this.http.post(constants.ApiServeLogin.queryShoppingCar, data);
    }
    // 添加购物车
    addShoppingCar(data) {
        return this.http.post(constants.ApiServeLogin.addShoppingCar, data);
    }
    // 获取商品列表
    getProcStandardsByColor(data) {
        return this.http.post(constants.ApiServeLogin.getProcStandardsByColor, data);
    }

    // 清空购物车
    delShoppingCarAll(data) {
        return this.http.post(constants.ApiServeLogin.delShoppingCarAll, data);
    }
    // 获取购物车列表
    delShoppingCar(data) {
        return this.http.post(constants.ApiServeLogin.delShoppingCar, data);
    }
    // 获取购物车列表
    placeOrder(data) {
        return this.http.post(constants.ApiServeLogin.placeOrder, data);
    }
    // 获评论列表
    getCommentList(data) {
        return this.http.post(constants.ApiServeNoLogin.queryRemarkList, data);
    }
    // 获评论列表
    writeComment(data) {
        return this.http.post(constants.ApiServeLogin.writeComment, data);
    }

    procIntegral(data) {
        return this.http.post(constants.ApiServeLogin.procIntegral, data);
    }

    getRotationChart(data) {
        return this.http.post(constants.ApiServeNoLogin.getRotationChart, data, { showLoading: false });
    }   // 获评论列表
    getFenqi(data) {
        return this.http.post(constants.ApiServeNoLogin.controlDerail, data, { showLoading: false });
    }
    // 获取图片地铁
    getImageUrl() {
        return this.http.getImageUrl();
    }

}
